var Util={
	checkboxToggle:function(controllerCheckbox,targetCheckboxes){
		if(controllerCheckbox && targetCheckboxes){
			if(targetCheckboxes.length==null)
				targetCheckboxes=[targetCheckboxes];			
			for (i = 0; i < targetCheckboxes.length; i=i+1) {
			   targetCheckboxes[i].checked = controllerCheckbox.checked;
			}
		}
	},
	trim:function(str){
		if(str){
			str=str.replace(/^\s*|\s*$/g,"");
		}
		return str;
	},
	appendClass:function(tag,className){
		tag.className=(tag.className.length>0?tag.className+" ":"")+className;

	},
	removeClass:function(tag,className){
		var re = new RegExp("(?:^|\\s)"+className+"(?=\\s|$)","g") 
		tag.className = tag.className.replace(re,"");
	}
};

function gotoPage(pageNo){
  var form = document.getElementById("searchForm");
  if(!form) {
	  form = document.forms[0];
  }
  if(form) {
      document.getElementById("pageNo").value = pageNo;
	  form.action = listUrl;
      form.submit();	
  }
}

function gotoPageByInput(){
  var pageNo = document.getElementById("pageNo").value;
  var re = new RegExp("^[0-9]*$");
  if (re.test(pageNo)){
    var pageCount =  2;
    if(pageNo > pageCount) {
		pageNo = pageCount;
	}
    if(pageNo < 1) {
		pageNo = 1;
	}
    gotoPage(pageNo);
  }else{
    alert('输入页码错误，请正确输入页码');
	document.getElementById("pageNo").value = '1';
    document.getElementById("pageNo").focus();
  }
}
